﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NineMine.Scm
{
    public abstract class Adapter
    {
        public virtual string ClientCommand 
        { 
            get { return ""; } 
        }

        public string ShellQuoteCommand
        {
            get
            {
#if NONWINDOWS
                return ShellQuote(ClientCommand);
#else
                return ClientCommand;
#endif
            }
        }

        public virtual List<string> ClientVersion
        {
            get { return new List<string>(); }
        }

        public string ClientVersionString
        {
            get
            {
                var result = string.Join(".", ClientVersion);
                if (string.IsNullOrEmpty(result))
                    result = "Unknown version";
                return result;
            }
        }

        public bool ClientVersionAbove(List<string> version)
        {
            return ClientVersionString.CompareTo(string.Join(".",version)) > 0 || ClientVersion.Count == 0;
        }

        public virtual bool ClientAvailable { get { return true; } }

        public string ShellQuote(string input)
        {
            return string.Format(@"""{0}""", input);
        }

        public virtual string AdapterName { get { return "Abstract"; } }

        public virtual bool SupportsCat { get { return true; } }

        public virtual bool SupportsAnnotate { get { return false; } }

        public string RootUrl { get; set; }

        public string Url { get; set; }

        public string PathEncoding { get; set; }

        public Info Info { get; set; }
    }
}
